$(function(){
	$('#'+tabId).css('display','none');
	showCondition(true,0,0,1,[]);
	//滚动条默认最上面
	scrollTo(0,0);
	tabId=$("#tabContent > .tab-pane.active").attr("id");
	var scoreQuota = [ {
		code : 'drg',
		name : 'DRGs指标',
		children : [ {
			name : "产能指标",
			children : [ {
				code : "TotalScore",
				name : "综合得分"
			}, {
				code : "CapacityScore",
				name : "产能得分"
			}, {
				code : "EfficiencyScore",
				name : "效率得分"
			}, {
				code : "QualityScore",
				name : "安全得分"
			} ]
		} ]
	} ]
	
	//是否显示全院科室绩效综合评价得分情况
	var isScoreShow = sysConfig.IS_SCORE_SHOW;
	if(isScoreShow==1){
		$('#'+tabId+' #scoreShow').show();
		// 加载全院科室绩效综合评价
		loadHomeScoreDepQuota(scoreQuota,"科室","depscorequotasDivId","depscore-ul");
		//加载科室绩效综合评价数据
		loadHomeScoreDepQuotaData(scoreQuota,"dep");
	}
	
	var deps=$('#deps_id').val();
	$('#'+tabId+' .date-from').html(paramTabPage[tabId].dateFrom.replace(/-/g,"."));
	$('#'+tabId+' .date-to').html(paramTabPage[tabId].dateTo.replace(/-/g,"."));
	if(deps==null||deps=="暂未授权科室"||deps==""){
		drgUI.confirm({
		    content : '您还没授权科室，请联系管理员授权，点击确定系统将退出！',
		    callSure : function() {           
		    $.post(contextPath+"/logout.dhc",function(data){
		            if(data.success){
		                window.location.href =data.data;
		            } 
		        });}
		    });
		    return;
	}else{
		$('#'+tabId).css('display','');
		paramTabPage[tabId].deps =deps;
		var depMap = {};
		$.ajax({
			url : contextPath+'/Department/findAllDep.dhc',
			async : false,
			data:{"depCode":deps},
			type : "POST",
			success : function(result) {
				for(var i = 0;i < result.data.length;i++ ){
					depMap[result.data[i].depCode] = result.data[i].depName;
				}
			}
		});
		drawDepTables(deps);//科室累计数据与绩效考核指标的比较情况
		//构造结构
		drawClinicDiv("");//医师DRGs绩效考核指标  结构
		drawClinicDiv("Perf");//各医师考核指标累计值比较情况  结构
		getClinicData(deps,depMap);//科室下医师指标累计值与标杆值比较图表
	}
	//科室累计数据与绩效考核指标的比较情况表格方法
	function drawDepTables(depCode,depMap){
		var param=drgUI.setAjaxData(tabId);
		param.isGetCc= "1" ;
		param.compareType="manage" ;
		param.msCode="manager_inner";
		param.monitorType="dep";
		param.quotaCode="AvgDaysAvgFeeDrugRatio";
		param.deps=paramTabPage[tabId].deps;
		$.post(contextPath + "/DrgsIndexCal/indexCal.dhc", param).done(function(result){
			 var id1='id1'+new Date().getTime();
				$('#'+tabId+' #depUnfinished-table').html('<table id="'+id1+'" class="stripe cc table" style="width:100%;"><caption>本期重点指标与目标值比较情况汇总</caption>'
						+'<thead><tr>'
						+'<td>科室名称</td>'
						+'<td>平均住院日</td>'
						+'<td>平均住院日目标值</td>'
						+'<td>平均住院日增长率</td>'
						+'<td>次均费用(元)</td>'
						+'<td>次均费用(元)目标值</td>'
						+'<td>次均费用增长率</td>'
						+'<td>药占比(%)</td>'
						+'<td>药占比(%)目标值</td>'
						+'<td>药占比增长率</td>'
						+'</tr></thead><tbody></tbody></table>');
				var columns=[ 
   	                     { "data": 'ddesc'},
   	                     { "data": "AvgDays"},
   	                     { "data": "AvgDayscc","type":"number-html" },
   	                     { "data": "AvgDaysRatio",
   	                       "render": function(obj, type, full) {
     	                    	   var AvgDays=full.AvgDays;
	  	                           var AvgDays_EX=full.AvgDayscc;
	  	                           return gridcompareValue(AvgDays,AvgDays_EX);
	  	                         }
   	                       },
   	                     { "data": "AvgFee" },
   	                     { "data": "AvgFeecc"},
	                     { "data": "AvgFeeRatio" ,
   	                       "render": function(obj, type, full) {
   	                    	   var AvgFee=full.AvgFee;
	  	                           var AvgFee_EX=full.AvgFeecc;
	  	                           return gridcompareValue(AvgFee,AvgFee_EX);
	  	                         
	  	                       }
   	                     },
     	                 { "data": "DrugRatio" },
 	                     { "data": "DrugRatiocc" },
 	                     { "data": "drugRatioRatio" ,
     	                    "render": function(obj, type, full) {
     	                    	 var DrugRatio=full.DrugRatio;
	  	                         var DrugRatio_EX=full.DrugRatiocc;
	  	                         return gridcompareValue(DrugRatio,DrugRatio_EX);
	  	                      }
     	                  }
   	                 ];
				var paramsDataTables={lengthChange:false,searching:false,info:false,rownumbers:true,tableTitle:'重点指标与目标值比较情况汇总表',columnDefs:[{"orderable": false,"targets": [ 0 ] }]};
				$('#'+tabId+' #'+id1).dataTableBasic(columns,result.data,paramsDataTables);

		})
	}

	//科室累计数据与绩效考核指标的比较情况表格
	function buildDepQuotaTargetTable(selector,titleData){
		if (titleData!=undefined) {
			var idT='id1'+new Date();
			var tableHtml = '<table id="'+idT+'" class="stripe cc table" style="width:100%;">'
			+'<thead>'
			+'<tr>'
			+'<td>指标项</td>'
			+'<td>平均住院日</td>'
			+'<td>次均费用（元）</td>'
			+'<td>药占比(%)</td>'
			+'</tr></thead>'
			+'<tr>'
			+'<td>累计值</td>'
			+'<td>'+compareValue(titleData.AvgDays,titleData.AvgDayscc)+'</td>'
			+'<td>'+compareValue(titleData.AvgFee,titleData.AvgFeecc)+'</td>'
			+'<td>'+comparePercent(titleData.DrugRatio,titleData.DrugRatiocc)+'</td>'
			+'</tr>'
			+'<tr>'
			+'<td>目标值</td>';
			if(titleData.AvgDayscc == undefined){
				tableHtml += '<td>_</td>';
			}else{
				tableHtml += '<td>'+titleData.AvgDayscc+'</td>';
			}
			if(titleData.AvgFeecc == undefined){
				tableHtml += '<td>_</td>';
			}else{
				tableHtml += '<td>'+titleData.AvgFeecc+'</td>';
			}
			if(titleData.DrugRatiocc == undefined){
				tableHtml += '<td>_</td>';
			}else{
				tableHtml += '<td>'+titleData.DrugRatiocc+'</td>';
			}
			tableHtml +='</tr></table>';
			$('#'+tabId+' #depUnfinished-table').html(tableHtml);
		}
	}

	//科室下医师指标累计值与标杆值比较图表
	function getClinicData(depCode,depMap){
		var deps = depCode.split(",");
		if (doctorSetConfig.length > 0) {
			if(doctorSetConfig[0]==1)
			{
				for (var i = 0;i<deps.length;i++)
				{
					var depCode = deps[i];
					loadClinicData("protomedicus",depCode,depMap[depCode]);
					loadClinicPerfData("protomedicus",depCode,depMap[depCode]);
				}
			}
			if(doctorSetConfig[1]==1)
			{
				for (var i = 0;i<deps.length;i++)
				{
					var depCode = deps[i];
					loadClinicData("clinic",depCode,depMap[depCode]);
					loadClinicPerfData("clinic",depCode,depMap[depCode]);
				}
			}
			if(doctorSetConfig[2]==1)
			{
				for (var i = 0;i<deps.length;i++)
				{
					var depCode = deps[i];
					loadClinicData("physician",depCode,depMap[depCode]);
					loadClinicPerfData("physician",depCode,depMap[depCode]);
				}
			}
			if(doctorSetConfig[3]==1)
			{
				for (var i = 0;i<deps.length;i++)
				{
					var depCode = deps[i];
					loadClinicData("resident",depCode,depMap[depCode]);
					loadClinicPerfData("resident",depCode,depMap[depCode]);
				}
			}
		}
	}
	function drawClinicDiv(postfix){
		var doctorul = '';
		var doctorStr = '';
		if (doctorSetConfig.length > 0) {
			if(doctorSetConfig[0]==1){
				doctorul += '<li role="presentation">';
				doctorul += '	<a href="#protomedicus'+postfix+'-'+tabId+'" role="tab" data-toggle="tab" class="top-tab">主任医师</a>';
				doctorul += '</li>';
				doctorStr += '<div role="tabpanel" class="tab-pane" id="protomedicus'+postfix+'-'+tabId+'">';
				doctorStr += '</div>';
			}
			if(doctorSetConfig[1]==1){
				doctorul += '<li role="presentation">';
				doctorul += '	<a href="#clinic'+postfix+'-'+tabId+'" role="tab" data-toggle="tab" class="top-tab">主诊医师</a>';
				doctorul += '</li>';
				doctorStr += '<div role="tabpanel" class="tab-pane" id="clinic'+postfix+'-'+tabId+'">';
				doctorStr += '</div>';
			}
			if(doctorSetConfig[2]==1){
				doctorul += '<li role="presentation">';
				doctorul += '	<a href="#physician'+postfix+'-'+tabId+'" role="tab" data-toggle="tab" class="top-tab">主治医师</a>';
				doctorul += '</li>';
				doctorStr += '<div role="tabpanel" class="tab-pane" id="physician'+postfix+'-'+tabId+'">';
				doctorStr += '</div>';
			}
			if(doctorSetConfig[3]==1){
				doctorul += '<li role="presentation">';
				doctorul += '	<a href="#resident'+postfix+'-'+tabId+'" role="tab" data-toggle="tab" class="top-tab">住院医师</a>';
				doctorul += '</li>';
				doctorStr += '<div role="tabpanel" class="tab-pane" id="resident'+postfix+'-'+tabId+'">';
				doctorStr += '</div>';
			}
			$('#' + tabId + ' #depDoctor'+postfix+'-ul').html(doctorul);
			$('#' + tabId + ' #depDoctor'+postfix+'Div').html(doctorStr);
			
			$('#' + tabId + ' #depDoctor'+postfix+'-ul li:eq(0)').addClass("active");
			$('#' + tabId + ' #depDoctor'+postfix+'Div>.tab-pane:eq(0)').addClass("active");
		}
	}
	
	function loadClinicData(doctor,depCode,depName){
		var param=drgUI.setAjaxData(tabId);
		param.isGetCc= "1" ;
		param.compareType="manage" ;
		param.pType=paramTabPage[tabId].pType;
		param.msCode="manager_inner";
		param.monitorType=doctor;
		param.quotaCode="AvgDaysAvgFeeDrugRatio"; 
		param.pardepCode=depCode; 
		$.post(contextPath + "/DrgsIndexCal/indexCal.dhc", param).done(function(result){
			getClinicCompareChart(result.data,doctor,depCode,depName) ; //科室下医师指标累计值与标杆值比较图
		})
	}
	
	function loadClinicPerfData(doctor,depCode,depName)
	{	
		var param=drgUI.setAjaxData(tabId);
		param.isGetCc= "0" ;
		param.pType=paramTabPage[tabId].pType;
		param.monitorType=doctor;
		param.quotaCode="DepPerfQuota"; 
		param.pardepCode=depCode; 
		$.post(contextPath + "/DrgsIndexCal/indexCal.dhc", param).done(function(result){
			getClinicTable(result.data,doctor,depCode,depName) ; //各医师DRGs相关考核指标累计值比较表
		})
		
	}

	//科室下主诊组指标累计值与标杆值比较图
	function getClinicCompareChart(charts,doctor,depCode,depName){
		depCode = new Base64().encode(depCode);
		$('#' + tabId + ' #depDoctorDiv #'+doctor+'-'+tabId).append('<div class = "depDoctor'+depCode+'"></div>');
		var height = $('#' + tabId + ' #depDoctorDiv #'+doctor +'-'+tabId+' .depDoctor'+depCode).height();
		$('#' + tabId + ' #depDoctorDiv #'+doctor +'-'+tabId+' .depDoctor'+depCode).height(300+height);
		
		$('#' + tabId + ' #depDoctorDiv #'+doctor +'-'+tabId+' .depDoctor'+depCode).append('<div class="paddingd10"></div>');
		$('#' + tabId + ' #depDoctorDiv #'+doctor +'-'+tabId+' .depDoctor'+depCode).append('<ul class="nav nav-tabs " role="tablist"><li role="presentation" class="active"><a role="tab" style="background: #59b8dc;color:rgba(255, 255, 255, 0.9)" data-toggle="tab"><i class="icon-medkit">&nbsp;</i>'+depName+'</a></li></ul>');
		$('#' + tabId + ' #depDoctorDiv #'+doctor +'-'+tabId+' .depDoctor'+depCode).append('<div id="depAvgDays-chart" class="col-md-4" style="height:250px;width:350px;"></div>');
		$('#' + tabId + ' #depDoctorDiv #'+doctor +'-'+tabId +' .depDoctor'+depCode).append('<div id="depAvgFee-chart" class="col-md-4" style="height:250px;width:350px;"></div>');
		$('#' + tabId + ' #depDoctorDiv #'+doctor +'-'+tabId+' .depDoctor'+depCode).append('<div id="depDrugRatio-chart" class="col-md-4" style="height:250px;width:350px;"></div>');
		var category = new Array();
		var dataAvgDays = new Array();
		var dataAvgFee = new Array();
		var dataDrugRatio = new Array();
		var dataAvgDaysCC = new Array();
		var dataAvgFeeCC = new Array();
		var dataDrugRatioCC = new Array();
		for (var i = 0; i < charts.length; i++) {
			category.push(charts[i].ddesc);
			dataAvgDays.push(charts[i].AvgDays);
			dataAvgFee.push(charts[i].AvgFee);
			dataDrugRatio.push(charts[i].DrugRatio);
			dataAvgDaysCC.push(charts[i].AvgDayscc);
			dataAvgFeeCC.push(charts[i].AvgFeecc);
			dataDrugRatioCC.push(charts[i].DrugRatiocc);
		}
		drawChart($('#'+tabId+' #depDoctorDiv #'+doctor+'-'+tabId +' .depDoctor'+depCode+' #depAvgDays-chart'),'平均住院日',category,dataAvgDays,dataAvgDaysCC);
		drawChart($('#'+tabId+' #depDoctorDiv #'+doctor+'-'+tabId +' .depDoctor'+depCode+' #depAvgFee-chart'),'次均费用（元）',category,dataAvgFee,dataAvgFeeCC);
		drawChart($('#'+tabId+' #depDoctorDiv #'+doctor+'-'+tabId +' .depDoctor'+depCode+' #depDrugRatio-chart'),'药占比（%）',category,dataDrugRatio,dataDrugRatioCC);
	
	}

	function getClinicTable(data,doctor,depCode,depName){
		depCode = new Base64().encode(depCode);
		
		$('#' + tabId + ' #depDoctorPerfDiv #'+doctor+'Perf-'+tabId).append('<div class = "depDoctorPerf'+depCode+'"></div>');
		var height = $('#' + tabId + ' #depDoctorPerfDiv #'+doctor+'Perf-'+tabId +' .depDoctorPerf'+depCode).height();
		$('#' + tabId + ' #depDoctorPerfDiv #'+doctor+'Perf-'+tabId+' .depDoctorPerf'+depCode).height(450+height);
		$('#' + tabId + ' #depDoctorPerfDiv #'+doctor+'Perf-'+tabId +' .depDoctorPerf'+depCode).append('<div class="paddingd10"></div>');
		$('#' + tabId + ' #depDoctorPerfDiv #'+doctor+'Perf-'+tabId +' .depDoctorPerf'+depCode).append('<ul class="nav nav-tabs " role="tablist"><li role="presentation" class="active"><a role="tab" style="background: #59b8dc;color:rgba(255, 255, 255, 0.9)" data-toggle="tab"><i class="icon-medkit">&nbsp;</i>'+depName+'</a></li></ul>');
		$('#' + tabId + ' #depDoctorPerfDiv #'+doctor+'Perf-'+tabId +' .depDoctorPerf'+depCode).append('<div class="col-md-5"><div id="clinicMC-chart" style="height:400px;width:450px;"></div></div>');
		$('#' + tabId + ' #depDoctorPerfDiv #'+doctor+'Perf-'+tabId +' .depDoctorPerf'+depCode).append('<div class="col-md-7"><div><h4 style="text-align:center">各医师DRG相关考核指标比较表</h4></div><div class="clinicMC-table"></div></div>');
		//legend图例翻页
		$('#'+tabId+' #depDoctorPerfDiv #'+doctor+'Perf-'+tabId +' .depDoctorPerf'+depCode+' #clinicMC-chart').after('<div class="js-eclegend-tool" style="position: absolute;right: 20px;top: 40%"></div>');
	    	
			var id1='id1'+new Date().getTime();
			$('#'+tabId+' #depDoctorPerfDiv #'+doctor+'Perf-'+tabId +' .depDoctorPerf'+depCode+' .clinicMC-table').html('<table id="'+id1+'" class="stripe cc table" style="width:100%;">'
					+'<thead><tr>'
					+'<td>医师</td>'
					+'<td>CMI</td>'
					+'<td>DRG组数</td>'
					+'<td>总权重</td>'
					+'<td>时间消耗<br>指数</td>'
					+'<td>费用消耗<br>指数</td>'
					+'<td>低风险<br>死亡人数</td>'
					+'</tr></thead><tbody></tbody></table>');
			var columns=[ 
                  { "mDataProp": 'ddesc'},
                  { "mDataProp": "CMI"},
                  { "mDataProp": "DRGCount"},
                  { "mDataProp": "TotalWeight"},
                  { "mDataProp": "TimeEff"},
                  { "mDataProp": "FeeEff"},
                    { "mDataProp": "Risk1DeadCaseCnt"}
              ];
			var paramsDataTables={searching:false,info:false,rownumbers:true,tableTitle:'医师DRG相关考核指标比较表',columnDefs:[{"orderable": false,"targets": [ 0 ] }]};
			var drawCallback= function( oSettings  ){
   	    	 var table = $(this);
   	    	$(this).find("tbody").off();
	    	 $(this).find("tbody").on( 'click', 'tr', function () {
	    	        $(this).toggleClass('selected');
	    	        var category = new Array();
	    		 	var series = new Array();
	    		 	table.find("tbody tr.selected").each(function(){
	    		 		category.push($(this).find("td:eq(0)").html());
	    		 		var serie = {name: $(this).find("td:eq(0)").html(), value:[Number($(this).find("td:eq(1)").html()), Number($(this).find("td:eq(6)").html()), Number($(this).find("td:eq(5)").html()), Number($(this).find("td:eq(4)").html()), Number($(this).find("td:eq(3)").html()), Number($(this).find("td:eq(2)").html())]}
	    		 		series.push(serie);
	    		 	})
	    		 	drawWebChart($('#'+tabId+' #depDoctorPerfDiv #'+doctor+'Perf-'+tabId +' .depDoctorPerf'+depCode+' #clinicMC-chart'),'',category,series);
	    	    } );
	    };
	    paramsDataTables.drawCallback=drawCallback ;
		var table = $('#'+tabId+' #depDoctorPerfDiv #'+doctor+'Perf-'+tabId +' .depDoctorPerf'+depCode+' #'+id1).dataTableBasic(columns,data,paramsDataTables);
			var tableObj=$('#'+tabId+' #depDoctorPerfDiv #'+doctor+'Perf-'+tabId +' .depDoctorPerf'+depCode+' #'+id1+'_wrapper .dataTables_scrollBody');
			if(data.length>0){
				tableObj.find("tbody").find("tr:eq(0)").click(); 
	    	}
	    	if(data.length>1){
	    		setTimeout(function(){
	    			tableObj.find("tbody").find("tr:eq(1)").click();
	    		},200) 
	    	}
	}

	//主诊组未达目标值汇总表格
	function buildClinicQuotaTargetTable(selector,data){
		
		if (data!=undefined) {
			var id1='id1'+new Date().getTime();
			$(selector).html('<table id="'+id1+'" class="stripe cc table" style="width:100%;">'
					+'<thead><tr>'
					+'<td>主诊组</td>'
					+'<td>平均住院日</td>'
					+'<td>次均费用（元）</td>'
					+'<td>药占比</td>'
					+'</tr></thead><tbody></tbody></table>');
			var columns=[ 
	                     { "data": 'ddesc'},
	                     { "data": "AvgDays" ,"type":"numeric-comma",
  	                       "render": function(obj, type, full) {
  	                    	 var AvgDays=full.AvgDays;
  	                           var AvgDays_EX=full.AvgDayscc;
  	                           return compareValue(AvgDays,AvgDays_EX);
  	                        
  	                         }
	                     },
	                     { "data": "AvgFee" ,"type":"numeric-comma",
	                       "render": function(obj, type, full) {
	                    	   var AvgFee=full.AvgFee;
  	                           var AvgFee_EX=full.AvgFeecc;
  	                           return compareValue(AvgFee,AvgFee_EX);
  	                         
  	                         }
	                     },
  	                     { "data": "DrugRatio" ,"type":"numeric-comma",
  	                       "render": function(obj, type, full) {
  	                    	 var DrugRatio=full.DrugRatio;
  	                           var DrugRatio_EX=full.DrugRatiocc;
  	                           return compareValue(DrugRatio,DrugRatio_EX);
  	                         
  	                         }
  	                     }
	                 ];
			$("#"+tabId+" #"+id+'datatable').dataTableBasic(columns,data,paramsDataTables);
		}
	}
	
	
	function drawChart(container,title,category,data,dataCC){
		var legend=['本期值','目标值'];
		var xAxis =[{type : 'category',data : category}];
		var yAxis=[{ type : 'value'}];
		var series = [
				        {
				            name:'本期值',
				            type:'bar',
				            data:data
				        },
				        {
				            name:'目标值',
				            type:'line',
				            data:dataCC
				        }
				    ];
		var chartParams={isDataZoom:true,legendPosition:'bottom'};
		barLineMixChartBasic(container,legend,series,xAxis,yAxis,title, '',chartParams);
	}
	
	function drawWebChart(container,title,category,data){
		var quotaCode=['CMI','Risk1Ratio','FeeEff','TimeEff','TotalWeight','DRGCount'];
		var quotaDesc =['CMI','低风险死亡人数','费用消耗指数','时间消耗指数','总权重','DRGs组数'];
		//调公共方法组装数据
		var lines = [];
		var quotas=[];
		var echartData=[];
		for(var o in category){
			lines.push({desc:category[o],data:[],dataShowValue: []});
		}
		for(var o in data){
			var temp={};
			for(var j in data[o].value){
				temp[quotaCode[j]]=data[o].value[j];
				temp[quotaCode[j]+'ShowValue']=data[o].value[j];
				if(o==0){//quotas只存一次，并max赋初始最大值
					quotas.push({code:quotaCode[j],name:quotaDesc[j],max:data[o].value[j]});
				}
				else{//如果o不等于0时，则判断当前quotas的max是否为最大值
					if(data[o].value[j]>quotas[j].max){
						quotas[j].max=data[o].value[j];
					}
				}
				
			}
			echartData.push(temp);
		}
		radarCharts(container, lines, echartData, quotas, '各医师指标值比较图', '');
	}
	
	/**
	 * 拼接div
	 * @param scoreQuota
	 * @param monitorName
	 * @param divId
	 * @param ulId
	 */
	function loadHomeScoreDepQuota(scoreQuota,monitorName,divId,ulId){
		if(!monitorName) monitorName = ""
		if(paramTabPage[tabId].compareType=="year"){
			compareName = "同期";
		}else if(paramTabPage[tabId].compareType=="month"){
			compareName = "上期";
		}else if(paramTabPage[tabId].compareType=="manage"){
			compareName = "绩效";
		}else if(paramTabPage[tabId].compareType=="std"){
			compareName = "标杆";
		}
		var str = '';
		var ul='';	
		for(var o in scoreQuota){
			var QuotaCode = scoreQuota[o].children;
			//拼接ul
			if(scoreQuota.length>1){
			if(o == 0){
				ul+='<li role="presentation" class="active">';
			}else{
				ul+='<li role="presentation">';
			}
			ul+='<a href="#'+scoreQuota[o].code+'QuaId2'+tabId+'" role="tab" data-toggle="tab" class="top-tab">'+scoreQuota[o].name+'</a>';
			ul+='</li>';
			$("#"+tabId+" #"+ulId).html(ul);
			}
		//开始拼接div
			if(o == 0){
				str+='<div role="tabpanel" class="tab-pane active" id="'+scoreQuota[o].code+'QuaId2'+tabId+'">';
			}else{
				str+='<div role="tabpanel" class="tab-pane" id="'+scoreQuota[o].code+'QuaId2'+tabId+'">';
			}
			//拼接页签
			for(var o in QuotaCode){
				var quotas = QuotaCode[o];
				str+=' <div class="paddingd10"> ';
				for(var o1 in quotas.children){				
					var quota = quotas.children[o1];
					var quotaCode = quota.code;
					var quotaName = quota.name;
					
					if(o1 == 0){
						ul+='<li role="presentation" class="active">';
					}else{
						ul+='<li role="presentation">';
					}
					ul+='<a href="#'+quotaCode+'-tc'+tabId+'" role="tab" data-toggle="tab">'+quotaName+'</a> ';
					ul+='</li>';
					$("#"+tabId+" #"+ulId).html(ul);
				}
					
				str+='   <div class="clearfix"></div> ';
				//拼接右侧表格
				str+='   <div class="tab-content"> ';
				for(var o1 in quotas.children){
					var quota = quotas.children[o1];
					var quotaCode = quota.code;
					var quotaName = quota.name;
					if(o1 == 0){
						str+='       <div role="tabpanel" class="tab-pane active" compareName="'+compareName+'" monitorName="'+monitorName+'" quotaName="'+quotaName+'" quotaCode="'+quotaCode+'" id="'+quotaCode+'-tc'+tabId+'"> ';
					}else{
						str+='       <div role="tabpanel" class="tab-pane" compareName="'+compareName+'" monitorName="'+monitorName+'" quotaName="'+quotaName+'" quotaCode="'+quotaCode+'" id="'+quotaCode+'-tc'+tabId+'"> ';
					}
					str+='           <div class="row padding100"> ';
					str+='               <div class="col-xs-5"> ';
					str+='                   <div class="echartscq" style=""></div> ';
					str+='               </div> ';
					str+='               <div class="col-xs-7 dataChangeSel"> ';
					str+='                   <table id="'+quotaCode+'-table'+tabId+'" class="table table-striped" cellspacing="0" width="100%" role="grid" aria-describedby="example_info"> ';
					str+='                       <caption class="contaotalsccq">'+monitorName+quotaName+'</caption> ';
					str+='                       <thead> ';
					str+='                           <tr role="row"> ';
					str+='                               <th tabindex="0" aria-controls="example" rowspan="1" colspan="1" aria-sort="ascending">'+monitorName+'</th> ';
					str+='                               <th tabindex="0" aria-controls="example" rowspan="1" colspan="1">本期值</th> ';
					str+='                               <th tabindex="0" aria-controls="example" rowspan="1" colspan="1">'+compareName+'值</th> ';
					str+='                               <th tabindex="0" aria-controls="example" rowspan="1" colspan="1">增长率</th> ';
					str+='                               <th tabindex="0" aria-controls="example" rowspan="1" colspan="1">操作</th> ';
					str+='                           </tr> ';
					str+='                       </thead> ';
					str+='                       <tbody></tbody> ';
					str+='                   </table> ';
					str+='               </div> ';
					str+='           </div> ';
					str+='       </div> ';
				}
				str+='   </div> ';
				str+=' </div> ';
			}
			str+='</div>';
			
		}	
		$("#"+tabId+" #"+divId).html(str);
	}
	/**
	 * 加载数据
	 * @param totalQuota
	 * @param monitorType
	 * @param functionOne
	 * @param operfunctionTwo
	 */
	function loadHomeScoreDepQuotaData(scoreQuota,monitorType,functionOne,operfunctionTwo){
		for(var o in scoreQuota){
			var quotaTypes = scoreQuota[o].children;
			for(var o in quotaTypes){
				var quotas = quotaTypes[o];
				for(var o1 in quotas.children){
					var quota = quotas.children[o1];
					var quotaCode = quota.code;
					var quotaName = quota.name;
					loadHomeScoreDepQuotaDatasub(quotaCode, quotaName,monitorType,functionOne,operfunctionTwo);//最后两个参数为本页面自定义的方法，当没有方法传递时传递空字符
					}
				}
		}
	}
	/**
	 * 循环加载div数据
	 * @param quotaCode
	 * @param quotaName
	 * @param monitorType
	 * @param functionOne
	 * @param operfunctionTwo
	 */
	function loadHomeScoreDepQuotaDatasub(quotaCode, quotaName,monitorType,functionOne,operfunctionTwo){	
			var param=drgUI.setAjaxData(tabId);
		    param.quotaCode=quotaCode;
		    param.monitorType=monitorType;
		    param.deps = "";
			$.post(contextPath+"/DrgsIndexCal/indexCal.dhc",param).done(function(data){
			var data = data.data;
			 var columns = [ 
		                    {  "data": "ccode",
		                    	"render":function(obj, type, full) {
		                    	return full.ddesc;
		               	 	 	}
		                     },
		                     { "data": "QuotaValue",
		                    	 "render":function(obj, type, full){ 
		                    		 return formatNumber(full.QuotaValue);
		                    	 	}
		                     },
		                     { "data": "QuotaValuecc",
		                    	 "render":function(obj, type, full){ 
		                    		 return formatNumber(full.QuotaValuecc);
		                    	 	}
		                    },
		                     { "data": "increasing","type": "number-fate",
		                       "render":function(obj, type, full){
		                    		 return gridcompareValue(full.QuotaValue, full.QuotaValuecc);
		                    	 }
		                     },
		                     { "datag": "OPERATION",
		                       "render":function(obj, type, full){
		                    	   return "<a title='趋势' href=\"javascript:trend('"+full.ccode+"', '"+full.ddesc+"', '"+monitorType+"', '"+quotaCode+"', '"+quotaName+"')\" class='trend-link'><i class='fa fa-line-chart'></i></a>";
		                       }  
		                     }
		                 ];
			 var paramsDataTables={order:[],columnDefs:[{"orderable": false,"targets":[4] }]};
			 $("#"+quotaCode+"-table"+tabId).drgsDataTable(columns, data, paramsDataTables);		
			})
		}
})



